def generate_anki_import_file(cards, output_path):
    """生成Anki导入文件
    
    Args:
        cards: 卡牌列表，每个卡牌是包含字段键值对的字典
        output_path: 输出文件路径
    """
    with open(output_path, 'w', encoding='utf-8') as f:
        f.write(f"#deck column:1\n")
        f.write(f"#separator:Tab\n")
        headers = ('deck_name', 'front', 'back')
        
        # 写入字段头（取第一个卡牌的字段作为列头）
        if cards:
            # 写入每条卡牌数据（匹配时忽略大小写）
            for card in cards:
                # 将卡片的key转为小写后匹配
                lower_card = {k.lower(): v for k, v in card.items()}
                f.write('\t'.join(str(lower_card.get(h.lower(), '')) for h in headers) + '\n')
